﻿using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using RestSharp;
using WeiTalk.OAuth;

namespace WeiTalk.Interfaces.Sina
{
    public class UserAPI : WeiBoAPIs
    {
        const string showUrl = "https://api.weibo.com/2/users/show.json";
        public UserAPI(RestClient client) : base(client) { }

        /// <summary>
        /// 根据用户ID获取用户信息
        /// </summary>
        /// <param name="callback"></param>
        /// <param name="uid"></param>
        /// <param name="screen_name">需要查询的用户昵称。</param>
        public void GetShow(Action<IRestResponse<WeiTalk.SinaEntities.User.Entity>> callback, string uid, string screen_name = null)
        {
            RestRequest request = new RestRequest(showUrl, Method.GET);
            request.AddParameter("source", Utility.ConsumerKey);
            request.AddParameter("access_token", Utility.AccessToken.Token);
            request.AddParameter("uid", uid);
            if (!String.IsNullOrEmpty(screen_name))
            {
                request.AddParameter("screen_name", screen_name);
            }
            request.AddParameter("timestamp", Guid.NewGuid().ToString());
            Client.ExecuteAsync<WeiTalk.SinaEntities.User.Entity>(request, callback);
        }
    }
}
